<%-- 
    Document   : feUserUpdate
    Created on : Sep 21, 2011, 3:12:38 PM
    Author     : Valentina
--%>

<%@page import="java.util.ResourceBundle"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>

<c:set var="language" value="${not empty param.language ? param.language : not empty language ? language : pageContext.request.locale}" scope="session" />
<fmt:setLocale value="${language}" />
<fmt:setBundle basename="Messages"/>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="default.css" rel="stylesheet" type="text/css" />
        <title><fmt:message key="page.text.userupdate.title"/></title>
    </head>
    <body>

        <jsp:include page="/WEB-INF/frontend/commons/header.jspf"></jsp:include>

            <table width="740" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                    <td>
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td><img src="images/spacer.gif" alt="" width="100" height="30" /></td>
                            </tr>
                            <tr>
                                <td class="text4"><fmt:message key="page.text.userupdate.title"/></td>
                        </tr>

                        <tr>
                            <td>
                                <ul class="error">
                                    <c:forEach var="error" items="${myErrors}" >
                                        <li>${error}</li>

                                    </c:forEach>
                                </ul>

                                <ul class="success">                                   
                                    <c:forEach var="success" items="${scflMessage}" >
                                        <li> ${success}</li>
                                    </c:forEach>
                                </ul>
                            </td>
                        </tr>

                        <tr>
                            <td>
                                <c:choose>
                                    <c:when test="${user!=null}">
                                        <form action="UserUpdateServlet?id=${user.id}" method="POST">
                                            <p>*<fmt:message key="page.text.name"/> <input type="text" name="name" value="${user.name}" size="20" /></p>
                                            <p>*<fmt:message key="page.text.login"/><input type="text" name="login" value="${user.login}" size="20" /></p>
                                            <p>*<fmt:message key="page.text.password"/><input type="password" name="password" value="${user.password}" size="20" /></p>
                                            <p><fmt:message key="page.text.group"/>
                                                <select name="idGroup">
                                                    <option value="0"><fmt:message key="page.text.selectone"/></option>
                                                    <c:forEach var="group" items="${groups}">
                                                        <c:choose>
                                                            <c:when test="${group.id==user.idgroup.id}">
                                                                <option value="${group.id}" SELECTED>${group.name}</option>
                                                            </c:when>
                                                            <c:otherwise>
                                                                <option value="${group.id}">${group.name}</option>
                                                            </c:otherwise>
                                                        </c:choose>

                                                    </c:forEach>
                                                </select>
                                            </p>
                                            <input type="submit" value="<fmt:message key="page.text.update"/>" />
                                        </form>
                                    </c:when>

                                    <c:otherwise>
                                        <form action="UserUpdateServlet" method="POST">
                                            <p>*<fmt:message key="page.text.name"/> <input type="text" name="name" value="${name}" size="20" /></p>
                                            <p>*<fmt:message key="page.text.login"/><input type="text" name="login" value="${login}" size="20" /></p>
                                            <p>*<fmt:message key="page.text.password"/><input type="text" name="password" value="${password}" size="20" /></p>
                                            <p><fmt:message key="page.text.group"/>
                                                <select name="idGroup">
                                                    <option value="0"><fmt:message key="page.text.selectone"/></option>
                                                    <c:forEach var="group" items="${groups}">
                                                        <option value="${group.id}">${group.name}</option>
                                                    </c:forEach>
                                                </select>
                                            </p>
                                            <input type="submit" value="<fmt:message key="page.text.update"/>" />
                                        </form>
                                    </c:otherwise>
                                </c:choose>


                            </td>
                        </tr>   

                    </table>
                </td>
            </tr>
        </table>

        <jsp:include page="/WEB-INF/frontend/commons/footer.jspf"></jsp:include>

    </body>
</html>